
package com.example.main.Conditional.Conditional;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

import java.util.List;


@Configuration
public class TestConfig {
    
     @Bean
     Test1 test1() {
     System.out.println("---------test1---------");
     return new Test1();
     }
    @Bean
    @Conditional(TestConditional.class)
    Test2 test2() {
        System.out.println("---------test2---------");
        return new Test2();
    }
    
    public class Test1 {
        
    }
    
    public class Test2 {
        
    }
    
    public static void main(String[] args) {


        //设置日志级别,去掉我不要的信息
        LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
        List<Logger> loggerList = loggerContext.getLoggerList();
        loggerList.forEach(logger -> {
            logger.setLevel(Level.ERROR);
        });

        //加载上下文
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.class);



    }
}